package com.tengju.bff.interfaces.manage.crm.activity;

import com.tengju.bff.interfaces.manage.common.facade.CommonManageFacade;
import com.tengju.bff.interfaces.manage.crm.activity.facade.ActivityTargetAnalysisFacade;
import com.tengju.bff.interfaces.manage.crm.activity.form.ActivityBaseQuery;
import com.tengju.bff.interfaces.manage.crm.activity.form.ActivityCalendarQuery;
import com.tengju.bff.interfaces.manage.crm.activity.form.ActivityCalendarTargetQuery;
import com.tengju.bff.interfaces.manage.crm.activity.form.ActivityTeamQuery;
import com.tengju.bff.interfaces.manage.crm.activity.vo.ActivityCalendarVO;
import com.tengju.bff.interfaces.manage.crm.activity.vo.ActivityTargetValueVO;
import com.tengju.bff.interfaces.shared.ApiResponse;
import com.tengju.bff.interfaces.shared.KVVO;
import com.tengju.bff.interfaces.shared.render.FunnelVO;
import com.tengju.bff.interfaces.shared.servlet.ManageEntrance;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author chenhang
 * @Date 2021/10/13
 */
@Validated
@RestController
@Api(tags = "生意参谋-销售活动目标-活动整体通用接口")
@RequestMapping(value = "manage/crm/activity/analysis/common")
@Slf4j
@ManageEntrance
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class ActivityCommonAnalysisController {

    private final ActivityTargetAnalysisFacade activityTargetAnalysisFacade;
    private final CommonManageFacade commonManageFacade;

    /******************************           活动日历               *********************************/

    @ApiOperation(value = "获取看板类型列表", notes = "获取看板类型列表")
    @RequestMapping(value = "/getKanbanTypes", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<List<KVVO<String, Integer>>> getKanbanTypes() {
        return ApiResponse.newSuccess(activityTargetAnalysisFacade.getKanbanTypes());
    }

    @ApiOperation(value = "获取活动目标日历看板", notes = "获取活动目标日历看板")
    @RequestMapping(value = "/getActivityCalendar", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<ActivityCalendarVO> getActivityCalendar(@RequestBody @Valid ActivityCalendarQuery query) {
        return ApiResponse.newSuccess(activityTargetAnalysisFacade.getActivityCalendar(query));
    }

    @ApiOperation(value = "获取活动日历目标值", notes = "获取活动日历目标值")
    @RequestMapping(value = "/getActivityCalendarTarget", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<ActivityTargetValueVO> getActivityCalendarTarget(@RequestBody @Valid ActivityCalendarTargetQuery query) {
        return ApiResponse.newSuccess(activityTargetAnalysisFacade.getActivityCalendarTarget(query));
    }

    @ApiOperation(value = "获取活动主体列表", notes = "获取销售类型列表")
    @RequestMapping(value = "/subjectList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<List<KVVO<String, Long>>> subjectList(@RequestBody @Valid ActivityBaseQuery query) {
        return ApiResponse.newSuccess(activityTargetAnalysisFacade.subjectList(query));
    }

    @ApiOperation(value = "活动转化漏斗", notes = "销售目标table")
    @RequestMapping(value = "/activityTransformFunnel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<List<KVVO>> activityTransformFunnel(@RequestBody @Valid ActivityBaseQuery query) {
        return ApiResponse.newSuccess(activityTargetAnalysisFacade.activityTransformFunnel(query));
    }



}
